<template>
	<view class="order">
		<Navbar>我的订单</Navbar>
		<view class="content">
			<view class="title">
				<view class="time">时间</view>
				<view>名称</view>
				<view>状态</view>
			</view>
			<scroll-view scroll-y class="scroll_view" @scrolltolower="loadmore">
				<view class="list">
					<view class="item" v-for="item in list" @click="router(`/pages/common/order_deta?id=${item.id}`)">
						<view class="time">{{item.created_at}}</view>
						<view>{{item.product_name}}</view>
						<view>{{item.status_name}}</view>
					</view>
				</view>
				<u-loadmore :status="loadmore_status" :color="$store.state.loadmoreColor"
					:lineColor="$store.state.loadmoreColor" line @loadmore="loadmore" />
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import {
		orderLists,
		userLog
	} from '@/request/api.js';
	export default {
		data() {
			return {
				active: "",
				scroll: [],
				list: []
			}
		},
		onLoad() {
			this.getList();
		},
		methods: {
			async getList() {
				let {
					list
				} = await orderLists({
					page: this.page,
					limit: this.limit
				});
				this.last_page = list.last_page;
				list = list.list;
				this.list = this.page == 1 ? list : [...this.list, ...list];
				this.loadmore_status = this.last_page == this.page ? 'nomore' : 'loadmore';
			},
			loadmore() {
				if (this.page < this.last_page) {
					this.page++;
					this.getList();
				}
			},
			changeActive(value) {
				this.active = value;
				this.page = 1;
				this.list = [];
				this.getList();
			}
		}
	}
</script>

<style scoped lang="scss">
	.order {
		height: 100vh;
		background: #29170D;
		overflow: hidden;

		.content {
			height: calc(100vh - #{$navbarHeight} - 100rpx);
			padding: 90rpx 50rpx 40rpx;
			box-sizing: border-box;
			background: url(#{$baseImageUrl}/my/bg2.png) no-repeat;
			background-size: 100% 100%;

			.title {
				height: 60rpx;
				display: flex;
				justify-content: space-between;

				view {
					flex: 1;
					text-align: center;
					color: #494338;
					font-size: 28rpx;
					font-weight: 400;
					font-family: SimSun;

					&.time {
						flex: 2;
					}
				}
			}

			.scroll_view {
				height: calc(100% - 60rpx);

				.list {
					.item {
						height: 58rpx;
						margin-bottom: 10rpx;
						background: url(#{$baseImageUrl}/my/item.png) no-repeat;
						background-size: 100% 100%;
						display: flex;
						justify-content: space-between;
						align-items: center;

						view {
							flex: 1;
							text-align: center;
							color: #494338;
							font-size: 26rpx;
							font-weight: 400;
							font-family: SimSun;

							&.time {
								flex: 2;
							}
						}
					}
				}
			}
		}
	}
</style>